/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.hl7.v3.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.hl7.v3.IVLPPDTS;
import org.hl7.v3.PIVLPPDTS;
import org.hl7.v3.PPDPQ;
import org.hl7.v3.V3Package;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>PIVLPPDTS</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.hl7.v3.impl.PIVLPPDTSImpl#getPhase <em>Phase</em>}</li>
 *   <li>{@link org.hl7.v3.impl.PIVLPPDTSImpl#getPeriod <em>Period</em>}</li>
 *   <li>{@link org.hl7.v3.impl.PIVLPPDTSImpl#getAlignment <em>Alignment</em>}</li>
 *   <li>{@link org.hl7.v3.impl.PIVLPPDTSImpl#isInstitutionSpecified <em>Institution Specified</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PIVLPPDTSImpl extends SXCMPPDTSImpl implements PIVLPPDTS {
	/**
	 * The cached value of the '{@link #getPhase() <em>Phase</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPhase()
	 * @generated
	 * @ordered
	 */
	protected IVLPPDTS phase;

	/**
	 * The cached value of the '{@link #getPeriod() <em>Period</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPeriod()
	 * @generated
	 * @ordered
	 */
	protected PPDPQ period;

	/**
	 * The default value of the '{@link #getAlignment() <em>Alignment</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAlignment()
	 * @generated
	 * @ordered
	 */
	protected static final Object ALIGNMENT_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getAlignment() <em>Alignment</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAlignment()
	 * @generated
	 * @ordered
	 */
	protected Object alignment = ALIGNMENT_EDEFAULT;

	/**
	 * The default value of the '{@link #isInstitutionSpecified() <em>Institution Specified</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isInstitutionSpecified()
	 * @generated
	 * @ordered
	 */
	protected static final boolean INSTITUTION_SPECIFIED_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isInstitutionSpecified() <em>Institution Specified</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isInstitutionSpecified()
	 * @generated
	 * @ordered
	 */
	protected boolean institutionSpecified = INSTITUTION_SPECIFIED_EDEFAULT;

	/**
	 * This is true if the Institution Specified attribute has been set.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 * @ordered
	 */
	protected boolean institutionSpecifiedESet;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PIVLPPDTSImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return V3Package.eINSTANCE.getPIVLPPDTS();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public IVLPPDTS getPhase() {
		return phase;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetPhase(IVLPPDTS newPhase, NotificationChain msgs) {
		IVLPPDTS oldPhase = phase;
		phase = newPhase;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, V3Package.PIVLPPDTS__PHASE, oldPhase, newPhase);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPhase(IVLPPDTS newPhase) {
		if (newPhase != phase) {
			NotificationChain msgs = null;
			if (phase != null)
				msgs = ((InternalEObject)phase).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - V3Package.PIVLPPDTS__PHASE, null, msgs);
			if (newPhase != null)
				msgs = ((InternalEObject)newPhase).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - V3Package.PIVLPPDTS__PHASE, null, msgs);
			msgs = basicSetPhase(newPhase, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, V3Package.PIVLPPDTS__PHASE, newPhase, newPhase));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PPDPQ getPeriod() {
		return period;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetPeriod(PPDPQ newPeriod, NotificationChain msgs) {
		PPDPQ oldPeriod = period;
		period = newPeriod;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, V3Package.PIVLPPDTS__PERIOD, oldPeriod, newPeriod);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPeriod(PPDPQ newPeriod) {
		if (newPeriod != period) {
			NotificationChain msgs = null;
			if (period != null)
				msgs = ((InternalEObject)period).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - V3Package.PIVLPPDTS__PERIOD, null, msgs);
			if (newPeriod != null)
				msgs = ((InternalEObject)newPeriod).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - V3Package.PIVLPPDTS__PERIOD, null, msgs);
			msgs = basicSetPeriod(newPeriod, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, V3Package.PIVLPPDTS__PERIOD, newPeriod, newPeriod));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object getAlignment() {
		return alignment;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAlignment(Object newAlignment) {
		Object oldAlignment = alignment;
		alignment = newAlignment;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, V3Package.PIVLPPDTS__ALIGNMENT, oldAlignment, alignment));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isInstitutionSpecified() {
		return institutionSpecified;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setInstitutionSpecified(boolean newInstitutionSpecified) {
		boolean oldInstitutionSpecified = institutionSpecified;
		institutionSpecified = newInstitutionSpecified;
		boolean oldInstitutionSpecifiedESet = institutionSpecifiedESet;
		institutionSpecifiedESet = true;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, V3Package.PIVLPPDTS__INSTITUTION_SPECIFIED, oldInstitutionSpecified, institutionSpecified, !oldInstitutionSpecifiedESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unsetInstitutionSpecified() {
		boolean oldInstitutionSpecified = institutionSpecified;
		boolean oldInstitutionSpecifiedESet = institutionSpecifiedESet;
		institutionSpecified = INSTITUTION_SPECIFIED_EDEFAULT;
		institutionSpecifiedESet = false;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.UNSET, V3Package.PIVLPPDTS__INSTITUTION_SPECIFIED, oldInstitutionSpecified, INSTITUTION_SPECIFIED_EDEFAULT, oldInstitutionSpecifiedESet));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isSetInstitutionSpecified() {
		return institutionSpecifiedESet;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case V3Package.PIVLPPDTS__PHASE:
				return basicSetPhase(null, msgs);
			case V3Package.PIVLPPDTS__PERIOD:
				return basicSetPeriod(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case V3Package.PIVLPPDTS__PHASE:
				return getPhase();
			case V3Package.PIVLPPDTS__PERIOD:
				return getPeriod();
			case V3Package.PIVLPPDTS__ALIGNMENT:
				return getAlignment();
			case V3Package.PIVLPPDTS__INSTITUTION_SPECIFIED:
				return isInstitutionSpecified() ? Boolean.TRUE : Boolean.FALSE;
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case V3Package.PIVLPPDTS__PHASE:
				setPhase((IVLPPDTS)newValue);
				return;
			case V3Package.PIVLPPDTS__PERIOD:
				setPeriod((PPDPQ)newValue);
				return;
			case V3Package.PIVLPPDTS__ALIGNMENT:
				setAlignment(newValue);
				return;
			case V3Package.PIVLPPDTS__INSTITUTION_SPECIFIED:
				setInstitutionSpecified(((Boolean)newValue).booleanValue());
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case V3Package.PIVLPPDTS__PHASE:
				setPhase((IVLPPDTS)null);
				return;
			case V3Package.PIVLPPDTS__PERIOD:
				setPeriod((PPDPQ)null);
				return;
			case V3Package.PIVLPPDTS__ALIGNMENT:
				setAlignment(ALIGNMENT_EDEFAULT);
				return;
			case V3Package.PIVLPPDTS__INSTITUTION_SPECIFIED:
				unsetInstitutionSpecified();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case V3Package.PIVLPPDTS__PHASE:
				return phase != null;
			case V3Package.PIVLPPDTS__PERIOD:
				return period != null;
			case V3Package.PIVLPPDTS__ALIGNMENT:
				return ALIGNMENT_EDEFAULT == null ? alignment != null : !ALIGNMENT_EDEFAULT.equals(alignment);
			case V3Package.PIVLPPDTS__INSTITUTION_SPECIFIED:
				return isSetInstitutionSpecified();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (alignment: ");
		result.append(alignment);
		result.append(", institutionSpecified: ");
		if (institutionSpecifiedESet) result.append(institutionSpecified); else result.append("<unset>");
		result.append(')');
		return result.toString();
	}

} //PIVLPPDTSImpl
